package model

import (
	"community_end/utils/errmsg"
	"gorm.io/gorm"
)

type Promotion struct {
	gorm.Model
	Title string `json:"title"`
	Link  string `json:"link"`
}

func (Promotion) TableName() string {
	return "promotion"
}

func SelectAllPromotion() ([]Promotion, int) {
	var p []Promotion
	err := db.Find(&p).Error
	if err != nil {
		return nil, errmsg.PROMOTION_SELECT_FAILED
	}
	return p, errmsg.SUCCESS
}
